<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1.0"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="telephone=no" name="format-detection"/>
    <title>个人中心</title>
    <link rel="stylesheet" href="css/H-ui.reset.css">
    <link rel="stylesheet" href="css/tongyong.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/alert.css">
    <link rel="stylesheet" href="css/myStyle.css" />
</head>
<body>

	<div class="personal_main">
    	<div class="personal_div">
           <a href="javascript:;" onclick="loginFun()">点击登录</a>
    	</div> 
    	<!-- <div style="position:absolute;top:0;padding: 100px 210px;">
            <img src="images/logo.png" style="display: block;width: 6.2rem;height: 6.2rem;" />
    	</div> -->
	</div>
	<div class="line"></div>
	<div class="line_info" id="selectMyInfo" >
		<img src="images/detail_02.png" /><span>我的资料</span>
	</div>
	<div class="line"></div>
	<div class="line_info" onclick="window.location.href='setting.html'">
		<img src="images/detail_03.png" /><span>设置</span>
	</div>
	
	<section class="list_footer">
    <section class="footer_term">
        <div class="footer_term_list footer_term_list_multiple">
        	<a onclick="toIndexPage()">
            	<img src="images/bottom_05.png" alt="">
            	<p>首页</p>
            </a>
        </div>
        <div class="footer_term_list footer_term_list_sum">
        	<a href="loan_list.html">
            	<img src="images/bottom_01.png" alt="">
            	<p>贷款超市</p>
        	</a>
        </div>
        <div class="footer_term_list footer_term_list_type">
            <a href="#">
            	<img src="images/bottom_03.png" alt="">
            	<p>个人中心</p>
            </a>
        </div>
    </section>
	</section>

	<script src="//cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="js/config.js"></script>
	<script type="text/javascript" src="js/alert.js"></script>
	<script type="text/javascript">
		$(".footer_term_list_type img").attr("src", "images/bottom_04.png");
	
		//跳转到index要带上channel
    	$(".footer_term_list_multiple a").click(function(){
    		var channel = localStorage.getItem("channel");
    		var num = localStorage.getItem("num");
    		window.location.href = "index.html?channel=" + channel + "&num=" + num;
    	});
		
		//如果登录成功显示用户手机号
		var token = localStorage.getItem("token");
		if (token != "" && token != null){
			var phoneNo = localStorage.getItem("phoneNo");
			$(".personal_div a").text(phoneNo);
		}
		
		//判断是否需要跳转到登录页面
		function loginFun(){
			var token = localStorage.getItem("token");
			//判断用户是否登录
			if (token != "" && token != null){
				window.location.href = "#";
			}else{
				window.location.href = "login.html";
			}
		}
		
		//查询用户信息
		$("#selectMyInfo").click(function(){
			var token = localStorage.getItem("token");
			//判断用户是否登录
			if (token != "" && token != null){
				var phoneNo = localStorage.getItem("phoneNo");
				var data = {
							"params": {
								"phoneNo": phoneNo
				   			 }
					   		}
				var jsonData = JSON.stringify(data);
				console.log(jsonData);
				$.ajax({
					url: urlLink + "/bMaMarketCustInfo/get",
					type: "POST",
					contentType: "application/json; charset=utf-8",
					data:jsonData,
					success:function(data){
						if (data.code == "0000") {
							var userName = data.result.userName;
							var age = data.result.age;
							var profession = data.result.profession;
							var sex = data.result.sex;
							var certNo = data.result.certNo;
							var monthIncome = data.result.monthIncome;
							var isCreditCard = data.result.isCreditCard;
							var region = data.result.region;
							window.location.href = "profile.html?userName=" + userName +"&age=" + age + "&profession=" + profession
									+ "&sex=" + sex + "&certNo=" + certNo + "&monthIncome=" + monthIncome + "&isCreditCard=" +
									isCreditCard + "&region=" + region;

						}else{
							alert(data.msg);
						}
					},
					error: function(data){
						console.log(data);
						alert("服务器繁忙");
					}
				})
			}else{
				window.location.href = "login.html";
			}
		});
		//window.location.href = "profile.html";
		
		
	</script>
	
</body>
</html>
